#include "sfml/Graphics/RenderWindow.hpp"
#include "Iniparser/iniparser.h"
#include "Settings/Settings.h"
#include "Systems/Systems.h"
#include "Systems/Memory.h"

#include "Game/game.h"

#include <string>
#include <cassert>



int GameMainLoop(GameSettings* io_gs, Systems* io_sys)
{
	Game* game = Z_NEW Game(io_sys, io_gs);
	Z_DELETE(game);
	return 0;
}


int main()
{
	/*	1) load inifile
		2) setup systems (graphics, sounds, fonts...)
		3) set MainMenu as current menu
		4) call the GameLoop
		5) shutdown systems
		6) save inifile
	*/

	GameSettingsManager gsm;
	const char* const iniFile = "GameSettings.ini";
	const auto isSettingsLoaded = gsm.Load(iniFile);
	if(!isSettingsLoaded)
		gsm.SetDefault();
	
	GameSettings gs = gsm.GetGameSettings();

	Systems sys;
	const auto areSystemsSetUp = sys.Setup(gsm.GetGameSettings());
	if(!areSystemsSetUp)
	{
		//Error
	}

	const auto gameExit = GameMainLoop(&gs, &sys);

	const auto areSystemsShutdown = sys.Shutdown();
	if(!areSystemsShutdown)
	{
		//Error
	}

	gsm.SetGameSettings(gs);
	gsm.Save(iniFile);

	return gameExit;
}